# #g++  $^ -o $@ -L./mylib/lib/ -lbundle -lpthread -ljsoncpp -lstdc++fs -std=c++17

cmake_minimum_required(VERSION 3.25)  
set(CMAKE_CXX_STANDARD 17)  
set(CMAKE_CXX_STANDARD_REQUIRED True)  
  
project(cloudServer)  
  
# 查找 libjsoncpp  
find_library(JSONCPP_LIBRARY NAMES libjsoncpp.so.1.7.4 PATHS /usr/lib/x86_64-linux-gnu)  
if(NOT JSONCPP_LIBRARY)  
    message(FATAL_ERROR "libjsoncpp.so.1.7.4 not found")  
endif()  

# 查找 libbundle  
find_library(BUNDLE_LIBRARY NAMES libbundle.a PATHS ./mylib/lib)  
if(NOT BUNDLE_LIBRARY)  
    message(FATAL_ERROR "libbundle.a not found")  
endif()  
  
# 查找 libmysqlclient
find_library(MYSQL_LIBRARY NAMES libmysqlclient.so PATHS /usr/lib/x86_64-linux-gnu)  
if(NOT MYSQL_LIBRARY)  
    message(FATAL_ERROR "libmysqlclient.so not found")  
endif()

# 查找 Boost 库
# find_library(BOOST_REGEX_LIBRARY NAMES libboost_regex.so PATHS /usr/lib/x86_64-linux-gnu)  
# if(NOT MYSQL_LIBRARY)  
#     message(FATAL_ERROR "libboost_regex.so not found")  
# endif()

# 添加可执行文件  
add_executable(cloudServer cloudServer.cc)  

# 为特定目标设置输出目录
set_target_properties(cloudServer PROPERTIES   
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/../  
)

# 链接库  
target_link_libraries(cloudServer  
    PRIVATE  
    ${JSONCPP_LIBRARY}  
    ${BUNDLE_LIBRARY}  
    ${MYSQL_LIBRARY}
    pthread  
    stdc++fs
)  